﻿using System;
using System.Data;

namespace MyLib {
	/// <summary>
	/// Parameter for query.
	/// </summary>
	public sealed class DbParameter {
		/// <summary>
		/// Name of parameter.
		/// </summary>
		public string Name { get; private set; }

		/// <summary>
		/// DbType of parameter.
		/// </summary>
		public DbParameterType DbType { get; private set; }

		/// <summary>
		/// 
		/// </summary>
		public DbParameterMatchType MatchType { get; private set; }

		/// <summary>
		/// Size of parameter.
		/// </summary>
		public int Size { get; private set; }

		/// <summary>
		/// 
		/// </summary>
		public ParameterDirection Direction { get; private set; }

		/// <summary>
		/// Value of parameter.
		/// </summary>
		public object Value { get; set; }

		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <param name="dbType"></param>
		/// <param name="value"></param>
		public DbParameter(string name, DbParameterType dbType, object value)
			: this(name, dbType, DbParameterMatchType.Exact, value) {
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <param name="dbType"></param>
		/// <param name="direction"></param>
		/// <param name="value"></param>
		public DbParameter(string name, DbParameterType dbType, ParameterDirection direction, object value)
			: this(name, dbType, DbParameterMatchType.Exact, value) {
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <param name="dbType"></param>
		/// <param name="matchType"></param>
		/// <param name="value"></param>
		public DbParameter(string name, DbParameterType dbType, DbParameterMatchType matchType, object value)
			: this(name, dbType, matchType, 0, value) {
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <param name="dbType"></param>
		/// <param name="matchType"></param>
		/// <param name="direction"></param>
		/// <param name="value"></param>
		public DbParameter(string name, DbParameterType dbType, DbParameterMatchType matchType, ParameterDirection direction, object value)
			: this(name, dbType, matchType, 0, direction, value) {
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <param name="dbType"></param>
		/// <param name="matchType"></param>
		/// <param name="size"></param>
		/// <param name="value"></param>
		public DbParameter(string name, DbParameterType dbType, DbParameterMatchType matchType, int size, object value)
			: this(name, dbType, matchType, size, ParameterDirection.Input, value) {
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <param name="dbType"></param>
		/// <param name="matchType"></param>
		/// <param name="direction"></param>
		/// <param name="size"></param>
		/// <param name="value"></param>
		public DbParameter(string name, DbParameterType dbType, DbParameterMatchType matchType, int size, ParameterDirection direction, object value) {
			Name = name;

			DbType = dbType;
			MatchType = matchType;
			Size = size;
			Direction = direction;
			Value = value;
		} // end of DbParameter.

	} // end of DbParameter.
}
